export default {
	data() {
		return {
			superId: '',
		}
	},
	onLoad(opt) {
		if (opt.super_id) {
			console.log("存在上级关系d==", opt.super_id)
			this.superId = opt.super_id
			this.login();
		} 
	},
	methods: {
	
		// 测试登录接口
		testlogin: function() {
			this.$api.testlogin().then((res) => {
				this.$store.commit("setUserInfo", res.data.userinfo);
			})
		},

		// 微信登录-获取code
		getWxCode() {
			console.log("微信登录-获取code")
			let that = this
			uni.login({
				provider: 'weixin',
				success: function(loginRes) {
					console.log("微信登录-获取code=>", loginRes);
					that.wxLogin(loginRes.code)
				}
			});
		},

		// 微信授权登录（第一步）
		wxLogin: function(code) {
			this.$api.wxlogin({
				code: code,
				super_id: this.superId
			}).then((res) => {
				this.$store.commit("setUserInfo", res.data.userinfo);
				
			});
		},
	


	},

}